package com.cote.douhahou.pretloan.msg;

import com.cote.douhahou.pretloan.beans.BaAkomapalendnkAccount;
import com.google.gson.Gson;

import org.json.JSONArray;
import org.json.JSONException;

import java.util.ArrayList;


public class AccAkomapalendountList {

    private static class Inner {
        private static final AccAkomapalendountList instance_akomapalend = new AccAkomapalendountList();
    }

    private AccAkomapalendountList() {}

    public static AccAkomapalendountList instance() {
        return Inner.instance_akomapalend;
    }

    private final ArrayList<BaAkomapalendnkAccount> bankAccountList = new ArrayList<>();

    private Runnable parseRunnable;

    public static void parse_akomapalend(JSONArray jsonArray) {

        Gson gson = new Gson();
        Inner.instance_akomapalend.bankAccountList.clear();
        for (int i=0;i<jsonArray.length();i++){
            try {
                BaAkomapalendnkAccount bankAccount = gson.fromJson(jsonArray.get(i).toString(), BaAkomapalendnkAccount.class );
                Inner.instance_akomapalend.bankAccountList.add(bankAccount);
            } catch (JSONException e) {
                e.printStackTrace();
            }
        }

        if (Inner.instance_akomapalend.parseRunnable!=null) Inner.instance_akomapalend.parseRunnable.run();

    }

    public ArrayList<BaAkomapalendnkAccount> getBankAccountList_akomapalend() {
        return bankAccountList;
    }

    public void setParseRunnable_akomapalend(Runnable parseRunnable) {
        this.parseRunnable = parseRunnable;
    }

}
